package com.youchuang.action.admin;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.youchuang.action.BaseAction;
import com.youchuang.common.Constant;
import com.youchuang.service.AdminService;

/**
 * 管理员修改密码
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/admin")
@ParentPackage("shopping-default")
public class PasswordUpdateAction extends BaseAction {
	private Logger logger = Logger.getLogger(PasswordUpdateAction.class.getSimpleName());
	private String olderpassword;
	private String password;
	private String repassword;
	private String resultnew;
	@Resource
	private AdminService adminService;

	@Action(value = "passwordUpdate", results = { @Result(name = Constant.SUCCESS, location = "/common/XYTipsWindowClose.jsp"),
			@Result(name = Constant.ERROR, location = "/common/error.jsp") })
	public String execute() throws Exception {
		logger.info("PasswordUpdateAction is execute");
		String result = adminService.updatePassword(olderpassword, password, repassword);
		if (result.equals(Constant.SUCCESS)) {
			resultnew = "恭喜您，密码修改成功。";
		} else {
			resultnew = "账号或密码输入有误，请重新输入！！！";
		}
		return result;
	}

	public String getOlderpassword() {
		return olderpassword;
	}

	public void setOlderpassword(String olderpassword) {
		this.olderpassword = olderpassword;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRepassword() {
		return repassword;
	}

	public void setRepassword(String repassword) {
		this.repassword = repassword;
	}

	public String getResultnew() {
		return resultnew;
	}

	public void setResultnew(String resultnew) {
		this.resultnew = resultnew;
	}

}
